import service from "@/service";

//列表
export function getRoleList(data) {
  let { page, pageSize } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role/list?page=${page}&pageSize=${pageSize}`,
    method: "POST",
    data,
  });
}

//查询【角色名称下拉框】
export function getRoleName(params) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role/getRoleListByTenantCode`,
    method: "GET",
    params,
  });
}

//停用
export function stopRole(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role/delete?id=${id}`,
    method: "POST",
  });
}

//启用
export function startRole(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role/startUsing?id=${id}`,
    method: "POST",
  });
}

//新增、编辑角色
export function operateRole(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role/add`,
    method: "POST",
    data,
  });
}

//查询设备列表
export function queryEquList(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-equ/queryEquList`,
    method: "POST",
    data,
  });
}

//设备配置提交
export function addEquiment(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role-equ/add`,
    method: "POST",
    data,
  });
}

//查询已选的组织列表
export function queryOrgList(data) {
  let { id } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role-org/detail?id=${id}`,
    method: "POST",
  });
}

//查询所有组织树
export function queryAllOrgTreeList(data = {}) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-org/getListDataQxAll`,
    method: "POST",
    data,
  });
}

//组织配置-新增
export function addOrg(data = {}) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role-org/add`,
    method: "POST",
    data,
  });
}

//查询-租户菜单信息
export function getTenantMenuByRoleId(params) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sysRoleTenantAndMenu/getTenantAndMenuByRoleId`,
    method: "GET",
    params,
  });
}

//查询-详情
export function getRoleDetail(id) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role/detail?id=${id}`,
    method: "POST",
  });
}

//查询已选人员
export function getChoosedUser(data) {
  let { roleId } = data;
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role-user/detail?roleId=${roleId}`,
    method: "POST",
  });
}

//人员配置 -提交
export function insertData(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sys-role-user/insertData`,
    method: "POST",
    data,
  });
}

//删除菜单
export function deleteData(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sysRoleTenantAndMenu/deleteData`,
    method: "POST",
    data,
  });
}

// 新增或编辑 菜单
export function saveOrUpdate(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sysRoleTenantAndMenu/saveOrUpdate`,
    method: "POST",
    data,
  });
}

//角色配置-查询详情
export function getTenantConfigDetail(data) {
  return service({
    baseUrl: "gateWaybaseUrl",
    url: `/user/sysRoleTenantAndMenu/getDetail`,
    method: "POST",
    data,
  });
}
